home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
63752
/
63752.xpi
/
chrome
/
flickriver
/
content
/
flickriver.js
< prev
next >
Wrap
Text File
|
2010-01-24
|
3KB
|
68 lines
/***************************************************************************
/*
/* View on Flickriver Firefox / Mozilla Add-on
/*
/* Written by Alex Sirota http://iosart.com/
/*
/* Copyright (c) 2010 Alex Sirota, All Rights Reserved
/*
/***************************************************************************/
var Flickriver = {
mainButtonPressed : function(evt) {
var shouldOpenInNewTab = evt && evt.button && (evt.button == 1) ? true : false;
var currentBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
var url = currentBrowser.currentURI.spec;
if (url.match(/http:\/\/(www.)?flickr.com\//)) {
var newURL = url.replace(/flickr.com/, 'flickriver.com');
if (shouldOpenInNewTab) {
gBrowser.selectedTab = gBrowser.addTab(newURL);
} else {
currentBrowser.loadURI(newURL);
}
} else {
Flickriver.showAlert('Pressing this button while on a Flick.com page will show the corresponding view on Flickriver');
if (!url.match(/http:\/\/(www.)?flickriver.com\//)) {
var newURL = 'http://www.flickriver.com/';
gBrowser.selectedTab = gBrowser.addTab(newURL);
}
}
},
installToolbarButton : function() {
try {
var firefoxNavBar = document.getElementById("nav-bar");
if (!firefoxNavBar) return;
var currentSet = firefoxNavBar.currentSet;
if (currentSet.indexOf("flickriver-button") == -1) {
var set;
if (currentSet.indexOf("urlbar-container") != -1) {
set = currentSet.replace(/urlbar-container/, "flickriver-button,urlbar-container");
} else {
set = currentSet + ",flickriver-button";
}
firefoxNavBar.setAttribute("currentset", set);
firefoxNavBar.currentSet = set;
document.persist("nav-bar", "currentset");
try {
BrowserToolboxCustomizeDone(true);
} catch (e) { }
}
} catch(e) { }
},
showAlert : function(msg) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
promptService.alert(null, 'Flickriver', msg);
},
onLoad : function() {
Flickriver.installToolbarButton();
}
}
window.addEventListener("load", Flickriver.onLoad, false);